package com.jysz.certificate.persistence.dao.system;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.jysz.certificate.persistence.dao.AbstractBaseDao;
import com.jysz.certificate.persistence.model.system.User;

@Repository
public class UserDao extends AbstractBaseDao<User, Long> {

	public User getUserByName(String name) {
		List<User> list = this.findBy("name", name);
		if(list!=null&&list.size()>0){
			return list.get(0);
		} 
		return null;
	}
	
	/**
	 * 根据属性和值,返回符合条件的第一条
	 * @param property
	 * @param value
	 * @return
	 */
	public User getUserByProperty(String property,String value) {
		List<User> list = this.findBy(property, value);
		if(list!=null&&list.size()>0){
			return list.get(0);
		} 
		return null;
	}
	
	public User getUserByJobNumber(String jobNumber) {
		List<User> list = this.findBy("jobNumber", jobNumber);
		if(list!=null&&list.size()>0){
			return list.get(0);
		} 
		return null;
	}
	
}
